<form name="listform" method="post">
<input type="hidden" name="method">
<table width="100%" border="0" cellpadding="8" cellspacing="0" class="list">
	<tr>
		<th width="10%">全选<input type="checkbox" onclick="checkAll(this)" id="checkall"></th>
		<th width="40%">建议内容</th>
		<th width="15%">称呼</th>
		<th width="15%">联系方式</th>
		<th width="10%">时间</th>
		<th width="10%"></th>
	</tr>
	{{foreach from=$row key=key item=item name="user"}}
	<tr {{if $smarty.foreach.user.index%2 eq '0'}}class="even"{{/if}}>
		<td align="center"><input type="checkbox" name="selectId[]" value="{{$item.id}}" onclick="checkOne()"></td>
		<td align="center">{{$item.content}}<span id="span_{{$item.id}}">{{if $item.answer}}<br/><font style="font-weight:700;color:green;">回复：</font><font color="red">{{$item.answer}}</font>{{/if}}</span><input class="ans" name="{{$item.id}}" type="button" value="回复" style="cursor:pointer;"></td>
		<td align="center">{{$item.name}}</td>
		<td align="center">{{$item.contact}}</td>
		<td align="center">{{$item.create_time}}</td>
		<td align="center"><input type="button" class="delbtn" value="删除" onclick="my_del('{{$smarty.server.PHP_SELF}}',{{$item.id}},this);"></td>
	</tr>
	{{/foreach}}
</table>
</form>
<div class="operation">
	<ul>
		<li><input type="button" value="批量删除" onclick="delAll();" style="cursor:pointer;"></li>
		<li><input type="button" value="永久删除" onclick="delCompletely();" style="background-color:red;cursor:pointer;"></li>
	</ul>
	<div style="clear:both;"></div>
</div>
<div id="dlg" style="border:3px solid green; height:150px; left: 100px; position:absolute; top:100px; width:250px; background-color:#CCFFFF; padding-left:5px; display:none;">
	<textarea rows="5" cols="25" name="content" id="dlg_content"></textarea>
	<input type="hidden" id="dlg_sugId">
	<input type="button" value="确认" style="cursor:pointer;" id="dlgCom">&nbsp;&nbsp;&nbsp;
	<input type="button" value="关闭" style="cursor:pointer;" onclick="$('#dlg').hide()">
</div>
<div class="fenye">{{$pageList}}</div>
<script type="text/javascript">
	function delAll()
	{
		var checked_objs = $("input[name='selectId[]']:checked");
		if(checked_objs.length < 1){
			alert("至少选择一项");
			return false;
		}
		if(!confirm("确认删除吗？"))return false;
		document.listform.method.value = 'delAll';
		document.listform.submit();
	}
	function delCompletely()
	{
		var checked_objs = $("input[name='selectId[]']:checked");
		if(checked_objs.length < 1){
			alert("至少选择一项");
			return false;
		}
		if(!confirm("确认永久删除吗？删除后数据将无法恢复！"))return false;
		document.listform.method.value = 'delCompletely';
		document.listform.submit();
	}
	$(document).ready(function(){
		var ansObjs = $(".ans");
		ansObjs.each(function(){
			$(this).click(function(e){
				var id = $(this).attr("name");
				$("#dlg_sugId").val(id);
				var ex=e.originalEvent.x||e.originalEvent.layerX||0; 
				var ey=e.originalEvent.y||e.originalEvent.layerY||0;
				$("#dlg").show().css("left",ex+"px").css("top",ey+"px");
			})
		})
		$("#dlgCom").click(function(){
			var content = $("#dlg_content").val();
			var id = $("#dlg_sugId").val();
			if(content == ""){
				alert("回复内容不能为空");
				return false;
			}
			$.ajax({
				type:"POST",
				url:"?method=answer&id="+id+"&content="+encodeURIComponent(content),
				success:function(msg){
					if(msg == 'ok'){
						$("#span_"+id).html("<br/><font style=\"font-weight:700;color:green;\">回复：</font><font color='red'>"+content+"</font>");
						$("#dlg").hide();
					}
				}            
			 });
		})
	})
</script>